<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/9
  Time: 16:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script src="js/jquery-3.6.0.min.js"></script>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h2>注册页面</h2>
    账号:<input type="text" name="username" id="username" value="">
        <span id="s1"></span>
    <br>
</body>
</html>
<script>
    //给input一个失去焦点事件
    $("#username").blur(function() {
        //获取value值
        var value = $(this).val();

        //ajax请求
        $.get("demo09Servlet",{"username" : value},function(obj) {


            //true  不让注册  false  让注册
            if(obj == "true") {
                $("#s1").text("用户名已存在");
                $("#s1").css("color","red");
            }else {
                $("#s1").text("√");
                $("#s1").css("color","green");

            }
        },"text");

    })
</script>
